<template>
  <div style="padding:10px;">
    <el-input type="text"
              placeHolder="每月可用次数"
              style="width:30%;margin-right:2%;"
              v-model.number="value"></el-input>
    <el-button type="primary"
               @click="mdfValue">修改</el-button>
  </div>
</template>

<script>

export default {
  name: "illegalQuery",
  data () {
    return {
      value: '',
      oldValue: '',
      id: ''
    }
  },
  methods: {
    async init () {
      let res = await this.api.illegalQuery({})
      this.id = res.data[0]['id'];
      this.value = res.data[0]['times'];
      this.oldValue = res.data[0]['times'];
    },
    mdfValue () {
      if (this.value === this.oldValue) {
        this.$message({
          message: '修改成功',
          type: 'success'
        });
      } else {
        this.api.mdfIllega({ id: this.id, times: this.value }).then(res => {
          this.$message({
            message: res.msg,
            type: res.code === 1 ? 'success' : 'error'
          })
        });
        this.init();
      }
    }
  },
  mounted () {
    this.init();
  }

}
</script>

<style scoped>
</style>
